package com.eonmind.user.mapper;

import com.eonmind.common.contract.data.base.BaseMongoMapper;
import com.eonmind.common.contract.enums.DelEnum;
import com.eonmind.common.provider.entity.user.UserNotificationPreference;
import com.mongoplus.conditions.query.QueryWrapper;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author Xujie
 * @since 2025/6/1 11:11
 **/

@Component
public class UserNotificationPreferenceMapper extends BaseMongoMapper<UserNotificationPreference> {
    public List<UserNotificationPreference> selectByUserId(Long userId) {
        QueryWrapper<UserNotificationPreference> eq = createMgoQuery()
                .eq(UserNotificationPreference::getUserId, userId)
                .eq(UserNotificationPreference::getDel, DelEnum.UN_DEL.getCode());
        return list(eq);
    }

    public UserNotificationPreference selectById(Long id) {
        QueryWrapper<UserNotificationPreference> eq = createMgoQuery()
                .eq(UserNotificationPreference::getId, id)
                .eq(UserNotificationPreference::getDel, DelEnum.UN_DEL.getCode());
        return one(eq);
    }
}
